<?php
declare (strict_types = 1);

namespace app\content\service\content;

use app\common\service\BaseService;
use app\content\logic\content\Agreement as AgreementLogic;
use think\annotation\Inject;
use think\facade\View;

/**
 * 协议管理
 */
class Agreement extends BaseService
{

    /**
     * @Inject()
     *
     * @var AgreementLogic
     */
    protected $agreementLogic;

    public function fetch(string $key)
    {
        $data = $this->agreementLogic->fetch($key);

        return $this->parseToData($data, 1, '获取成功');
    }

    /**
     * 返回页面
     *
     * @param string $key
     * @param int    $mhm_id
     * @return string
     */
    public function content(string $key, int $mhm_id)
    {
        $info = $this->agreementLogic->getInfoByWhere([
            'key'    => $key,
            'mhm_id' => $mhm_id
        ]);

        View::assign('title', $info->title);
        view::assign('content', $info->content);

        return View::fetch('agreement/content');
    }
}
